﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using Konekcija.Core.Reporting.Dto.Application.Configurations;

namespace Konekcija.Core.Reporting.Mappings.Configurations
{
    public class RegionMap : ClassMap<Region>
    {
        public RegionMap()
        {
            Schema("config");
            Table("Regions");

            Id(x => x.Id).GeneratedBy.GuidComb().Not.Nullable();
            Map(x => x.ParentCategoryid).Nullable();
            Map(x => x.Path).Nullable();
            Map(x => x.WebsiteId).Column("WebsiteId")
                .Not.Insert().Not.Update().Nullable();
            Map(x => x.Importance).Nullable();
            Map(x => x.ImageUrl).Nullable();
            Map(x => x.NumActiveContent).Nullable();
            Map(x => x.DateCreated).Nullable();

            References(x => x.Website).Nullable();

            HasMany(x => x.RegionLanguages)
                .LazyLoad()
                .Inverse()
                .AsBag()
                .Key(k => k.Not.Nullable())
                .KeyColumn("RegionId")
                .Cascade.None();

            HasMany(x => x.Items)
                .LazyLoad()
                .Inverse()
                .AsBag()
                .Key(k => k.Not.Nullable())
                .KeyColumn("RegionId")
                .Cascade.None();
        }
    }
}
